package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.PixelSnapping;
	import flash.filters.BlurFilter;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Point;

	public final class BitmapPlay extends PlayBase
	{
		public function BitmapPlay(){super();}
		
		private var bmpData:BitmapData;
		private const bitmap:Bitmap = new Bitmap(bmpData,PixelSnapping.NEVER, true);
		override protected function addedToStage():void
		{
			addChild(bitmap);
		} 

		override protected function resized(width:uint, height:uint):void
		{
			bmpData = new BitmapData(width, height, false, 0);
			bitmap.bitmapData = bmpData;
		}
		override protected function enterFrame():void
		{
			bmpData.lock();
			var color:uint;
			var x:uint;
			var y:uint;
			for(var i:int = 1 << 5; i -- > 0 ;)
			{
				x = random *  stageWidth;
				y = random *  stageHeight;
				color = random * 0xFFFFFF;
				bmpData.setPixel(x,y,color);
			}
			doBlur();
			zoom();
			bmpData.unlock();
		}
		private function zoom():void
		{
			const colorTransform:ColorTransform = new ColorTransform();
			const matrix:Matrix = new Matrix();
				colorTransform.alphaMultiplier = .9;
			//m.translate(-bmpd.width*.05,-bmpd.height*.05);
			
				matrix.translate(- random, - random);
				matrix.scale(1.0001, 1.0001);
//				matrix.rotate(.0001);
			bmpData.draw(bmpData, matrix, colorTransform);
		}

		private const point:Point = new Point();
		private const blurFilter:BlurFilter = new BlurFilter(1.05, 1, 1);
		private function doBlur():void	{bmpData.applyFilter(bmpData,bmpData.rect, point, blurFilter);}
	}
}